<?php 
include_once('connection/connection.php');
//session_start();
//ob_start();
include('header.php');
include('menu.php');
$check=$_SESSION['check'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<script language="javascript" src="js/ajaxFunction1.js"></script>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<title>Questionnaire No.3</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
		$fclick = true;
		$loc_id = $_SESSION['loc_id'];
		$total_sub_pump=$_POST['total_sub_pump'];
		$total_mono_block_pump=$_POST['total_mono_block_pump'];
		$total_centrifugal_pump=$_POST['total_centrifugal_pump'];
		$total_single_phase_pump=$_POST['total_single_phase_pump'];
		$num_cwr=$_POST['num_cwr'];
		$sc_st_cwr=$_POST['sc_st_cwr'];
		/*$num_glsr=$_POST['num_glsr'];
		$sc_st_glsr=$_POST['sc_st_glsr'];
		$num_glr=$_POST['num_glr'];
		$sc_st_glr=$_POST['sc_st_glr'];*/
		$num_ohsr=$_POST['num_ohsr'];
		$sc_st_ohsr=$_POST['sc_st_ohsr'];
		$psp_total=$_POST['psp_total'];
		$psp_sc_st=$_POST['psp_sc_st'];
		$success = 0;
		if($_POST['total_sub_pump']!=0 || $_POST['total_sub_pump']!='' || $_POST['total_mono_block_pump']!=0 || $_POST['total_mono_block_pump']!='' || $_POST['total_centrifugal_pump']!=0 || $_POST['total_centrifugal_pump']!='' || $_POST['total_single_phase_pump']!=0 || $_POST['total_single_phase_pump']!='' || $_POST['num_cwr']!=0 || $_POST['num_cwr']!='' || $_POST['num_ohsr']!=0 || $_POST['num_ohsr']!='' || $_POST['psp_total']!=0 || $_POST['psp_total']!='')
		{
			$qr1="UPDATE tbl_dtls_q3_loc SET total_sub_pump='$total_sub_pump', total_mono_block_pump='$total_mono_block_pump', total_centrifugal_pump='$total_centrifugal_pump', total_single_phase_pump='$total_single_phase_pump', cwr_no='$num_cwr', sc_st_cwr='$sc_st_cwr', ohsr_no='$num_ohsr', sc_st_ohsr='$sc_st_ohsr', psp_total='$psp_total', psp_sc_st='$psp_sc_st' WHERE id='$loc_id'";	
			$result1=mysql_query($qr1);
			if($result1)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 1;
			}			
			for($i=1; $i<=$total_sub_pump; $i++)
			{
				$sub_id='sub_id'.$i;
				$sub_location='sub_location'.$i;
				$sub_longitude='sub_longitude'.$i;
				$sub_latitude='sub_latitude'.$i;
				$sub_status='sub_status'.$i;
				$sub_id=$_POST[$sub_id];
				$sub_location=$_POST[$sub_location];
				$sub_longitude=$_POST[$sub_longitude];
				$sub_latitude=$_POST[$sub_latitude];
				$sub_status=$_POST[$sub_status];
				$qr2="INSERT INTO tbl_dtls_q3_supply_infra_ground(loc_id, ground_id, ground_location, ground_longitude, ground_latitude, ground_status) VALUES ('$loc_id', '$sub_id', '$sub_location', '$sub_longitude', '$sub_latitude', '$sub_status')";
				$result2=mysql_query($qr2);
			}	
			if($result2)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 2;
			}
		
			for($i=1; $i<=$total_mono_block_pump; $i++)
			{
				$mono_id='mono_id'.$i;
				$mono_location='mono_location'.$i;
				$mono_longitude='mono_longitude'.$i;
				$mono_latitude='mono_latitude'.$i;
				$mono_status='mono_status'.$i;
				$mono_id=$_POST[$mono_id];
				$mono_location=$_POST[$mono_location];
				$mono_longitude=$_POST[$mono_longitude];
				$mono_latitude=$_POST[$mono_latitude];
				$mono_status=$_POST[$mono_status];
				$qr3="INSERT INTO tbl_dtls_q3_supply_infra_ground(loc_id, ground_id, ground_location, ground_longitude, ground_latitude, ground_status) VALUES ('$loc_id', '$mono_id', '$mono_location', '$mono_longitude', '$mono_latitude', '$mono_status')";
				$result3=mysql_query($qr3);
			}
			if($result3)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 3;
			}
					
			for($i=1; $i<=$total_centrifugal_pump; $i++)
			{
				$centi_id='centi_id'.$i;
				$centi_location='centi_location'.$i;
				$centi_longitude='centi_longitude'.$i;
				$centi_latitude='centi_latitude'.$i;
				$centi_status='centi_status'.$i;
				$centi_id=$_POST[$centi_id];
				$centi_location=$_POST[$centi_location];
				$centi_longitude=$_POST[$centi_longitude];
				$centi_latitude=$_POST[$centi_latitude];
				$centi_status=$_POST[$centi_status];
				$qr4="INSERT INTO tbl_dtls_q3_supply_infra_ground(loc_id, ground_id, ground_location, ground_longitude, ground_latitude, ground_status) VALUES ('$loc_id', '$centi_id', '$centi_location', '$centi_longitude', '$centi_latitude', '$centi_status')";
				$result4=mysql_query($qr4);
			}
			if($result4)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 4;
			}
						
			for($i=1; $i<=$total_single_phase_pump; $i++)
			{
				$sp_id='sp_id'.$i;
				$sp_location='sp_location'.$i;
				$sp_longitude='sp_longitude'.$i;
				$sp_latitude='sp_latitude'.$i;
				$sp_status='sp_status'.$i;
				$sp_id=$_POST[$sp_id];
				$sp_location=$_POST[$sp_location];
				$sp_longitude=$_POST[$sp_longitude];
				$sp_latitude=$_POST[$sp_latitude];
				$sp_status=$_POST[$sp_status];
				$qr5="INSERT INTO tbl_dtls_q3_supply_infra_ground(loc_id, ground_id, ground_location, ground_longitude, ground_latitude, ground_status) VALUES ('$loc_id', '$sp_id', '$sp_location', '$sp_longitude', '$sp_latitude', '$sp_status')";
				$result5=mysql_query($qr5);
			}
			if($result5)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 5;
			}
					
			for($i=1; $i<=$num_cwr; $i++)
			{
				$cwr_id='cwr_id'.$i;
				$cwr_location='cwr_location'.$i;
				$cwr_longitude='cwr_longitude'.$i;
				$cwr_latitude='cwr_latitude'.$i;
				$capacity_cwr='capacity_cwr'.$i;
				$cwr_status='cwr_status'.$i;
				$cwr_id=$_POST[$cwr_id];
				$cwr_location=$_POST[$cwr_location];
				$cwr_longitude=$_POST[$cwr_longitude];
				$cwr_latitude=$_POST[$cwr_latitude];
				$capacity_cwr=$_POST[$capacity_cwr];
				$cwr_status=$_POST[$cwr_status];
				$qr6="INSERT INTO tbl_dtls_q3_reserv2(loc_id, reserv_id,reserv_location, reserv_longitude, reserv_latitude, reserv_cap, reserv_status) VALUES ('$loc_id', '$cwr_id', '$cwr_location', '$cwr_longitude', '$cwr_latitude', '$capacity_cwr', '$cwr_status')";
				$result6=mysql_query($qr6);
			}
			if($result6)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 6;
			}
			
								
			for($i=1; $i<=$num_ohsr; $i++)
			{
			$ohsr_id='ohsr_id'.$i;
			$ohsr_location='ohsr_location'.$i;
			$ohsr_longitude='ohsr_longitude'.$i;
			$ohsr_latitude='ohsr_latitude'.$i;
			$capacity_ohsr='capacity_ohsr'.$i;
			$ohsr_status='ohsr_status'.$i;
			$ohsr_id=$_POST[$ohsr_id];
			$ohsr_location=$_POST[$ohsr_location];
			$ohsr_longitude=$_POST[$ohsr_longitude];
			$ohsr_latitude=$_POST[$ohsr_latitude];
			$capacity_ohsr=$_POST[$capacity_ohsr];
			$ohsr_status=$_POST[$ohsr_status];
			$qr7="INSERT INTO tbl_dtls_q3_reserv2(loc_id, reserv_id, reserv_location, reserv_longitude, reserv_latitude, reserv_cap, reserv_status) VALUES ('$loc_id', '$ohsr_id', '$ohsr_location', '$ohsr_longitude', '$ohsr_latitude', '$capacity_ohsr', '$ohsr_status')";
			$result7=mysql_query($qr7);
			}
			if($result7)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 7;
			}
			
					
			for($i=1; $i<=$psp_total; $i++)
			{
				$psp_taps='psp_taps'.$i;
				$psp_loc='psp_loc'.$i;
				$psp_longitude='psp_longitude'.$i;
				$psp_latitude='psp_latitude'.$i;
				$psp_glr='psp_glr'.$i;
				$psp_cwt='psp_cwt'.$i;
				$sc_st='sc_st'.$i;
				$psp_taps=$_POST[$psp_taps];
				$psp_loc=$_POST[$psp_loc];
				$psp_longitude=$_POST[$psp_longitude];
				$psp_latitude=$_POST[$psp_latitude];
				$psp_glr=$_POST[$psp_glr];
				$psp_cwt=$_POST[$psp_cwt];
				$sc_st=$_POST[$sc_st];
				$qr8="INSERT INTO tbl_dtls_q3_psp(loc_id, psp_taps, psp_loc, psp_longitude, psp_latitude, psp_glr, psp_cwt, sc_st) VALUES ('$loc_id', '$psp_taps', '$psp_loc', '$psp_longitude', '$psp_latitude', '$psp_glr', '$psp_cwt', '$sc_st')"; 
				$result8=mysql_query($qr8);
			}
				//echo "<br>";	
			if($result8)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 8;
			}
					
		}
		else if($_POST['total_sub_pump']=0 || $_POST['total_mono_block_pump']=0 || $_POST['total_centrifugal_pump']=0 || $_POST['total_single_phase_pump']=0 || $_POST['num_cwr']=0 || $_POST['num_ohsr']=0 || $_POST['psp_total']=0)
		{
			$qr9="UPDATE tbl_dtls_q3_loc SET total_sub_pump='$total_sub_pump', total_mono_block_pump='$total_mono_block_pump', total_centrifugal_pump='$total_centrifugal_pump', total_single_phase_pump='$total_single_phase_pump', cwr_no='$num_cwr', sc_st_cwr='$sc_st_cwr', ohsr_no='$num_ohsr', sc_st_ohsr='$sc_st_ohsr', psp_total='$psp_total', psp_sc_st='$psp_sc_st' WHERE id='$loc_id'";	
			$result9=mysql_query($qr9);
			if($result9)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 9;
			}
									
		}	
			$qr10="UPDATE tbl_dtls_q3_loc SET status='1' WHERE id='$loc_id'";	
			$result10=mysql_query($qr10);
			if($result10)
			{
				//echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form. Now you can go on <a href="home.php">home</a> page or fill the <a href="questionnaire3.php">Questionnaire 3</a> form again.</span>';
				//exit();
				$success = 10;
			}	
			
			$q="SELECT usertype FROM tbl_dtls_createuser WHERE loginid='$loginid'";
			//echo $q;
			$res=mysql_query($q);
			$x=mysql_fetch_array($res);
			$user_type=$x['usertype'];
			$user_id=$_SESSION['loginid'];
			$form_id=$_SESSION['form_id'];
			$user_name=$_SESSION['name'];
			//$user_type=$_SESSION['usertype'];
			$ip=$_SERVER['REMOTE_ADDR'];
			$qr11="INSERT INTO tbl_dtls_user_history(user_id, form_id, action_id, ip_address, modify_date, user_type, user_name) VALUES ('$user_id', '$form_id', '3', '$ip', NOW(), '$user_type', '$user_name')";
			//echo $q5;
			$result11=mysql_query($qr11);
			if($result11)
			{
				$success = 11;
				echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form.</span>';
				echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>';echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>';
				echo '<span class="successmssg">For filling another form click here <a href="questionnaire3.php">Questionnaire 3</a></span>';
				exit();
			}
			else
			{
				echo '<span class="successmssg">Unsuccessful Insertion</span>';
			}			
}
else
{
	$fclick = false;
	$flag=0;
}
?>		
<div align="center">
<form action="" method="post" enctype="multipart/form-data" name="questionnaire3_7" id="questionnaire3_7" onSubmit="return validate7()">
<input type="hidden" name="check_value" id="check_value" value="<?php echo $check;?>" class="txt5">
	<table border="0" width="800" id="table1" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30">
			<p align="center">
			<font face="Verdana" style="font-size: 10pt; font-weight: 700" color="#000000">
			Questionnaire No. 3</font></td>
		</tr>
		<tr>
			<td height="19">
			<p align="center">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">For 
			Field Survey (Village Level questionnaire) </font></td>
		</tr>
		<tr>
			<td height="18">
			<p align="center">
			<font style="font-size: 8.5pt" face="Arial" color="#000000">Page 7</font></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="20"><font color="#000000">&nbsp;
			<span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt">15. Water Supply 
			Infrastructure on Ground&nbsp;</font></span></font></td>
		</tr>
		<tr>
			<td>&nbsp;
			</td>
		</tr>
		<tr>
			<td>
			<table border="0" width="800" id="table9" cellpadding="0">
				<tr>
					<td width="137" align="center" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">
					Type</font></td>
					<td height="27" align="center" width="657" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">
					Total Nos.</font></td>
				</tr>
				<tr>
					<td width="137">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Submersible 
					pump</font></td>
				  	<td width="657" align="center">
		  		  <input type="text" name="total_sub_pump" id="total_sub_pump" size="20" class="txt5" onKeyUp="show_subm();numeric(this)"></td>
				</tr>
				<tr>
					<td></td>
                    <td><div id="subm"></div></td>
				</tr>
				<tr>
					<td width="137">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Mono- 
					Block pump</font></td>
					<td width="657" align="center">
				  <input type="text" name="total_mono_block_pump" id="total_mono_block_pump" size="20" class="txt5" onKeyUp="show_mono();numeric(this)"></td>
					</tr>
				<tr>
					<td></td>
                    <td><div id="mono"></div></td>
				  </tr>
				<tr>
					<td width="137">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Centrifugal 
					pump</font></td>
					<td width="657" align="center">
				  <input type="text" name="total_centrifugal_pump" id="total_centrifugal_pump" size="20" class="txt5" onKeyUp="show_centi();numeric(this)"></td>
				</tr>
				<tr>
					<td></td>
                    <td><div id="centi"></div></td>
				  </tr>
				<tr>
					<td width="137">
					<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Single 
					phase pump</font></td>
				  <td width="657" align="center"><input type="text" name="total_single_phase_pump" id="total_single_phase_pump" size="20" class="txt5" onKeyUp="show_sp();numeric(this)"></td>
				</tr>
				<tr>
					<td></td>
                    <td><div id="sp"></div></td>
				  </tr>
			</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="20"><font color="#000000">&nbsp;
			</font><span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">&nbsp;Reservoirs</font></span></td>
		</tr>
		<tr>
			<td height="130">
			<table width="800" height="119" border="0" cellpadding="0" id="table10">
				<tr>
					<td width="33%" align="center" bgcolor="#F7E6B7">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">
						Type</font></td>
					<td height="27" align="center" width="46%" bgcolor="#F7E6B7">
						<font face="Verdana" style="font-size: 8.5pt" color="#990000">
						Total Nos.</font>					</td>
					<td height="27" align="center" width="21%" bgcolor="#F7E6B7">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">
						In SC/ ST bastis (Nos.)</font></td>
					</tr>
				<tr>
					<td width="33%">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Clear 
						Water Reservoir(CWR)- &nbsp;Underground</font></td>
				  <td width="46%" align="center"><input type="text" name="num_cwr" id="num_cwr" size="20" class="txt5" onKeyUp="show_cwr_cap();numeric(this)"></td>
				  <td width="21%" align="center"><input type="text" name="sc_st_cwr" id="sc_st_cwr" size="20" class="txt5" onKeyUp="numeric(this)">                  </td>
				</tr>
				<tr>
					
                    <td colspan="3"><div id="cwr_cap"></div></td>
				</tr>	
				
				<tr>
					<td width="33%">
						<font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;Over 
						Head Service Reservoir (OHSR)</font></td>
				  <td width="46%" align="center">
		  		  <input type="text" name="num_ohsr" id="num_ohsr" size="20" class="txt5" onKeyUp="show_ohsr_cap();numeric(this)"></td>
					<td width="21%" align="center">
				  <input type="text" name="sc_st_ohsr" id="sc_st_ohsr" size="20" class="txt5" onKeyUp="numeric(this)"></td>
				</tr>
				<tr>
                    <td colspan="3"><div id="ohsr_cap"></div></td>
              </tr>
			</table>
		  </td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="20"><font color="#000000">&nbsp;</font>
				<span style="font-weight: 700"><font face="Arial" style="font-size: 8.5pt" color=																						                "#000000">Public Stand Post (PSP) </font></span>
			</td>
		</tr>
		<tr>
			<td>
					<table border="0" width="100%" id="table12" cellpadding="0">
								<tr>
									<td width="32%" align="center" bgcolor="#F7E6B7" colspan="2">
										<font style="font-size: 8.5pt" face="Verdana" color="#990000">
										No. of PSPs</font></td>
								</tr>
								<tr>
									<td width="32%" align="center" bgcolor="#F7E6B7">
										<font style="font-size: 8.5pt" face="Verdana" color="#990000">
										Total</font></td>
									<td width="32%" align="center" bgcolor="#F7E6B7">
										<font style="font-size: 8.5pt" face="Verdana" color="#990000">
										In SC / ST Bastis</font></td>
								</tr>
								<tr>
									<td width="13%" align="center"><input type="text" name="psp_total" id="psp_total" size="20"                                        class="txt5" onKeyUp="showpsp();numeric(this)"></td>
									<td width="13%" align="center">
										<input type="text" name="psp_sc_st" id="psp_sc_st" size="20" class="txt5" onKeyUp="numeric(this)">																	 									</td>
								</tr>
								<tr>
									<td colspan="2"><div id="show_psp"></div></td>
								</tr>
						</table>
		  			</td>
				</tr>		
			<tr><td>&nbsp;</td></tr>
			<tr><td>&nbsp;</td></tr>
	<tr>
		<td align="center">
			<input type="submit" value="Click for Continue" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px">
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>
